/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UI;

import S_Algorithm.DiskManage;
import S_Algorithm.DiskScheduleUtil;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import UI.LineCharts;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.JPanel;

/**
 *
 * @author DannyYo
 */
public class DS_Manager extends javax.swing.JFrame {
    private boolean run = false;
    private JPanel newPanel2;
    private JPanel newPanel1;
    private int[] aa;
    private JPanel newPanel3;
    private JPanel newPanel4;

    /**
     * Creates new form DS_Manager
     */
    public DS_Manager() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        FCFS_Radio = new javax.swing.JRadioButton();
        SSTF_Radio = new javax.swing.JRadioButton();
        SCAN_Radio = new javax.swing.JRadioButton();
        CSCAN_Radio = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        InitIndex = new javax.swing.JTextField();
        startButton = new javax.swing.JButton();
        sPanel = new JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        buttonGroup1.add(FCFS_Radio);
        FCFS_Radio.setText("先来先服务算法（FCFS）");
        FCFS_Radio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FCFS_RadioActionPerformed(evt);
            }
        });

        buttonGroup1.add(SSTF_Radio);
        SSTF_Radio.setText("最短寻道时间优先算法（SSTF）");
        SSTF_Radio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SSTF_RadioActionPerformed(evt);
            }
        });

        buttonGroup1.add(SCAN_Radio);
        SCAN_Radio.setText("电梯调度算法（SCAN）");
        SCAN_Radio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SCAN_RadioActionPerformed(evt);
            }
        });

        buttonGroup1.add(CSCAN_Radio);
        CSCAN_Radio.setText("循环扫描算法（CSCAN）");
        CSCAN_Radio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CSCAN_RadioActionPerformed(evt);
            }
        });

        jLabel1.setText("假设磁盘磁道数为 1500，磁头初始位置设置为");

        InitIndex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                InitIndexActionPerformed(evt);
            }
        });

        startButton.setText("开始模拟");
        startButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(56, 56, 56)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(CSCAN_Radio)
                    .addComponent(SCAN_Radio)
                    .addComponent(SSTF_Radio)
                    .addComponent(FCFS_Radio)
                    .addComponent(startButton, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(InitIndex, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(InitIndex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addComponent(FCFS_Radio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SSTF_Radio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(SCAN_Radio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(CSCAN_Radio)
                .addGap(32, 32, 32)
                .addComponent(startButton, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(20, Short.MAX_VALUE))
        );

        sPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout sPanelLayout = new javax.swing.GroupLayout(sPanel);
        sPanel.setLayout(sPanelLayout);
        sPanelLayout.setHorizontalGroup(
            sPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 698, Short.MAX_VALUE)
        );
        sPanelLayout.setVerticalGroup(
            sPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jPanel3.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel2.setText("各算法的磁头移动道数比较如下：");

        jLabel3.setText("FCFS:");

        jLabel4.setText("SSTF:");

        jLabel5.setText("SCAN:");

        jLabel6.setText("CSCAN:");

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField3)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jTextField2))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel3, jLabel4, jLabel5, jLabel6});

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jTextField1, jTextField2, jTextField3, jTextField4});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel3, jLabel4, jLabel5, jLabel6});

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(sPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(11, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(sPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void FCFS_RadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FCFS_RadioActionPerformed
        // TODO add your handling code here:
//        sPanel.getGraphics().clearRect(0,0,sPanel.getWidth(),sPanel.getHeight());
//         sPanel.getGraphics().clearRect(0,0,sPanel.getWidth(),sPanel.getHeight());
//          Graphics g =sPanel.getGraphics();
//           int barHeight = 20;
//        int barWidth = 30;

//        loadData(1);

//        g.setColor(myColor.myBlue);
//		g.fillRect(78+12+25, 400-barHeight, barWidth, barHeight);
//                 g.setColor(myColor.myBlack);
//               g.setFont(new java.awt.Font("微软雅黑", 0, 18));
//                g.drawString("良好",88+12+25, 420);
//		g.drawString(numstr, 98+12+25, 400-barHeight);
//                sPanel.paintComponents(g);
//                sPanel.repaint();
        if(run){
            
         sPanel.removeAll();
         newPanel1.setVisible(true);
           newPanel1.setBounds(0, 0, sPanel.getWidth(), sPanel.getHeight());//设置newPanel的位置，必不可少
            sPanel.add(newPanel1);
            sPanel.revalidate();
            sPanel.repaint();
        }else{
            return;
        }
    }//GEN-LAST:event_FCFS_RadioActionPerformed

    private void SSTF_RadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SSTF_RadioActionPerformed
        // TODO add your handling code here:
//         sPanel.getGraphics().clearRect(0,0,sPanel.getWidth(),sPanel.getHeight());
//          Graphics g =sPanel.getGraphics();
//           int barHeight = 20;
//        int barWidth = 30;
//        String numstr="asaa";
//        
//        g.setColor(myColor.myCyan);
//		g.fillRect(126+12+12+50, 400-barHeight, barWidth, barHeight);
//                 g.setColor(myColor.myBlack);
//               g.setFont(new java.awt.Font("微软雅黑", 0, 18));
//		g.drawString("中等",136+12+12+50, 420);
//		g.drawString(numstr, 146+12+12+50, 400-barHeight);
//                 sPanel.paintComponents(g);
//        loadData(2);
//        if(run){

        
         sPanel.removeAll();
         
         newPanel2.setVisible(true);
         newPanel2.setBounds(0, 0, sPanel.getWidth(), sPanel.getHeight());//设置newPanel的位置，必不可少
            sPanel.add(newPanel2);
            sPanel.revalidate();
            sPanel.repaint();
//        }else{
//            return;
//        }
    }//GEN-LAST:event_SSTF_RadioActionPerformed

    private void InitIndexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_InitIndexActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_InitIndexActionPerformed

    private void startButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startButtonActionPerformed
             DiskScheduleUtil DSU = new DiskScheduleUtil();
            aa = DSU.createDiskRequest();       
           if(FCFS_Radio.isSelected())
             loadData(1);
 if(SSTF_Radio.isSelected())
             loadData(2);
  if(SCAN_Radio.isSelected())
             loadData(3);
  if(CSCAN_Radio.isSelected())
             loadData(4);
  run =true;
               // TODO add your handling code here:
    }//GEN-LAST:event_startButtonActionPerformed

    private void SCAN_RadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SCAN_RadioActionPerformed
        // TODO add your handling code here:
//         sPanel.getGraphics().clearRect(0,0,sPanel.getWidth(),sPanel.getHeight());
        
//        Graphics g = sPanel.getGraphics();
//        int barHeight = 20;
//        int barWidth = 30;
//        String numstr = "asaa";
//        g.setColor(myColor.myGreen);
//        g.fillRect(174 + 12 + 24 + 75, 400 - barHeight, barWidth, barHeight);
//        g.setColor(myColor.myBlack);
//        g.setFont(new java.awt.Font("微软雅黑", 0, 18));
//        g.drawString("及格", 184 + 12 + 24 + 75, 420);
//        g.drawString(numstr, 194 + 12 + 24 + 75, 400 - barHeight);
//        sPanel.paintComponents(g);
         sPanel.removeAll();
         
         newPanel3.setVisible(true);
         newPanel3.setBounds(0, 0, sPanel.getWidth(), sPanel.getHeight());//设置newPanel的位置，必不可少
            sPanel.add(newPanel3);
            sPanel.revalidate();
            sPanel.repaint();
    }//GEN-LAST:event_SCAN_RadioActionPerformed

    private void CSCAN_RadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CSCAN_RadioActionPerformed
        // TODO add your handling code here:
//         sPanel.getGraphics().clearRect(0,0,sPanel.getWidth(),sPanel.getHeight());
//        Graphics g = sPanel.getGraphics();
//        int barHeight = 20;
//        int barWidth = 30;
//        String numstr = "asaa";
//        g.setColor(myColor.myYellow);
//        g.fillRect(222 + 12 + 36 + 100, 400 - barHeight, barWidth, barHeight);
//        g.setColor(myColor.myBlack);
//        g.setFont(new java.awt.Font("微软雅黑", 0, 18));
//        g.drawString("不及格", 232 + 12 + 36 + 100, 420);
//        g.drawString(numstr, 240 + 12 + 36 + 100, 400 - barHeight);
//        sPanel.paintComponents(g);
          sPanel.removeAll();
         
         newPanel4.setVisible(true);
         newPanel4.setBounds(0, 0, sPanel.getWidth(), sPanel.getHeight());//设置newPanel的位置，必不可少
            sPanel.add(newPanel4);
            sPanel.revalidate();
            sPanel.repaint();
    }//GEN-LAST:event_CSCAN_RadioActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField1ActionPerformed
    private void loadData(int m) {

//        DiskScheduleUtil DSU = new DiskScheduleUtil();
//        int[] a1 = DSU.createDiskRequest();
//        if(!run)
//            return;
        
        if (InitIndex.getText().length() == 0 || Integer.parseInt(InitIndex.getText()) < 1 || Integer.parseInt(InitIndex.getText()) > 1500) {
            JOptionPane.showMessageDialog(null, "提示：磁头的序列范围1~1500！磁头从小号到大号寻道！！");
            return;
        }

        int initIndex = Integer.parseInt(InitIndex.getText());
        LineCharts linecharts = new LineCharts();
        //
DiskManage DM = new DiskManage();

            Object[] o = DM.Manage(m, initIndex, aa);
            int[] a1 = (int[]) o[0];
            double sum1 = (double) o[1];
            jTextField1.setText(String.valueOf(sum1));
             newPanel1 = linecharts.createDemoLine(a1, "FCFS");
            //
            int[] a2 = (int[]) o[2];
//             for(int i=1;i<=10;i++)
//                System.out.println(a2[i]+" ");
            double sum2 = (double) o[3];
            jTextField2.setText(String.valueOf(sum2));
            //JPanel newPanel = linecharts.createDemoLine(a, "SSTF");
newPanel2 = linecharts.createDemoLine(a2, "SSTF");

int[] a3 = (int[]) o[4];
//             for(int i=1;i<=10;i++)
//                System.out.println(a3[i]+" ");
            double sum3 =  (double)  o[5];
            jTextField3.setText(String.valueOf(sum3));
newPanel3 = linecharts.createDemoLine(a3, "SCAN");

int[] a4 = (int[]) o[6];
//             for(int i=1;i<=10;i++)
//                System.out.println(a4[i]+" ");
            double sum4 =  (double)  o[7];
            jTextField4.setText(String.valueOf(sum4));
newPanel4 = linecharts.createDemoLine(a4, "CSCAN");

            
        if (m == 1) {
            newPanel1.setBounds(0, 0, sPanel.getWidth(), sPanel.getHeight());//设置newPanel的位置，必不可少

            newPanel1.setVisible(true);
            sPanel.removeAll();
            sPanel.add(newPanel1);
            sPanel.repaint();
        } else if (m == 2) {
          
            newPanel2.setBounds(0, 0, sPanel.getWidth(), sPanel.getHeight());//设置newPanel的位置，必不可少

            newPanel2.setVisible(true);
            sPanel.removeAll();
            sPanel.add(newPanel2);
            sPanel.repaint();
        }else if (m == 3) {
          
            newPanel3.setBounds(0, 0, sPanel.getWidth(), sPanel.getHeight());//设置newPanel的位置，必不可少

            newPanel3.setVisible(true);
            sPanel.removeAll();
            sPanel.add(newPanel3);
            sPanel.repaint();
        }else if (m == 4) {
          
            newPanel4.setBounds(0, 0, sPanel.getWidth(), sPanel.getHeight());//设置newPanel的位置，必不可少

            newPanel4.setVisible(true);
            sPanel.removeAll();
            sPanel.add(newPanel4);
            sPanel.repaint();
        }

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(DS_Manager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DS_Manager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DS_Manager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DS_Manager.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new DS_Manager().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton CSCAN_Radio;
    private javax.swing.JRadioButton FCFS_Radio;
    private javax.swing.JTextField InitIndex;
    private javax.swing.JRadioButton SCAN_Radio;
    private javax.swing.JRadioButton SSTF_Radio;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JPanel sPanel;
    private javax.swing.JButton startButton;
    // End of variables declaration//GEN-END:variables
}
